#import "composants.typ": *

#set page(
  paper: "presentation-4-3",
  margin: 0cm,
)

// Font
#set text(
  font: "New Computer Modern",
  size: 20pt,
  fill: black,
)
#set math.mat(delim: "[")

// Page de garde
#slide[
  #place(center + horizon)[
    #graphe_tanner_fond(1cm, 1.5)
  ]
  #v(1fr)
  #align(center + horizon)[
    #pad(x: 2cm)[
      #text(size: 3em, weight: "bold", fill: black)[#titre]

      #text(size: 1.2em, weight: "bold", fill: black)[#auteur]

      #h(0.5em)

      #text(size: 1.2em, fill: black)[n°#numero]

      #text(size: 0.95em, fill: black)[#annee]
    ]
  ]
  #v(1fr)
]

#myslide("Plan")[
  #design_plan((
    [Introduction],
    [Codes linéaires],
    [LDPC],
    [Codage],
    [Décodage],
    [Analyse],
  ))
]

#myslide("Introduction : Communication Numérique")[
  #place(center + horizon)[
    #canal_shannon_intro()
  ]
]

#myslide("Introduction : Utilisation")[
  #align(center + horizon)[
    #grid(
      columns: (1.5fr, 1.5fr),
      gutter: 1.5cm,
      align: center + horizon,
      [
        #box(width: 80%)[
          #stack(
            dir: ttb,
            spacing: -0.5em,
            image("src/athena_fidus_no_text.jpg", width: 100%),
            align(left)[
              #box(
                inset: (x: 5pt, y: 0pt),
                text(size: 0.45em, fill: white)[* https://gallery.ariane.group *],
              )
            ],
          )
        ]
        #v(0.5em)
        Athena-Fidus
      ],
      [
        #box(width: 80%)[
          #stack(
            dir: ttb,
            spacing: -0.5em,
            image("src/runcamfpv2.png", width: 100%),
            align(left)[
              #box(
                inset: (x: 5pt, y: 0pt),
                text(size: 0.45em, fill: white)[* https://www.runcam.com/ *],
              )
            ],
          )
        ]
        #v(0.5em)
        Module OpenIPC
      ],
    )
  ]
]

#myslide("Problématique")[
  #place(center + horizon, dy: 8.1cm)[#graphe_tanner_fond(0.9cm, 1.75)]
  #place(center + horizon, dy: 7.7cm)[
    #block(width: 100%)[
      #text(size: 1.2em, weight: "bold", fill: black)[
        Comment utiliser les codes LDPC pour garantir la fiabilité d'une transmission en présence de bruit ?
      ]
    ]
  ]
]

#myslide("Définition : Codes Linéaires en Bloc")[
  #definition(titre: [Code $display((n,k) in NN^2)$])[
    $cal(C)$ sous-espace vectoriel de dimension $k$ de $FF_2^n$
  ]

  #[
    #set text(size: 1.1em)
    - $k$ : longueur du message original
    - $n$ : longueur du mot de code
    - $m = n - k$ : nombre de bits de parités
  ]

  #definition(titre: "Encodage")[
    $Phi : FF_2^k & -> FF_2^n in cal(L)(FF_2^k, FF_2^n)$
  ]

  #v(-1.3em)

  #uncover(2)[
    #align(center + horizon)[
      #plongement_schema()
    ]
  ]
]

#myslide("Définition : Matrice Génératrice")[
  #definition(titre: "Matrice Génératrice")[
    $G in cal(M)_(k,n)(FF_2)$ dont les lignes sont une base de $cal(C)$
  ]

  #definition(titre: "Encodage")[
    Pour un message $u in FF_2^k$ le mot de code $c in cal(C)$ est :
    $
      c = Phi(u) = u dot.o G
    $
  ]

  #definition(titre: "Forme systématique")[
    $
      G = mat(
        I_k, P;
        augment: #1,
        delim: "[",
      )
    $
  ]

  #[
    #set text(size: 1.2em)
    - Pour $u in FF_2^k, space display(u dot.o G = mat(u, u dot.o P; augment: #1, delim: "[",))$

    - $P in cal(M)_(k ,(n-k))(FF_2)$ matrice de parité\
  ]
]

#myslide("Définition : Matrice de Contrôle")[
  #definition(titre: "Matrice de Contrôle")[
    $
      H = mat(
        P^top, I_(n-k);
        augment: #1,
        delim: "[",
      )
    $
  ]
  #[
    #set text(size: 1.2em)
    - $cal(C) = ker(H) = {v in FF_2^n | H dot.o v^top = 0}$

    - $display(G dot.o H^top = 0)$
  ]

  #definition(titre: "Syndrome")[
    Pour un vecteur reçu $r = c + e, space s in FF_2^(n - k)$
    $
      s = H r^top = H c^top + H e^top = 0 + H e^top
    $
  ]
  #[
    #set text(size: 1.2em)
    - Si $s = 0, space r$ est un mot de code valide
    - Sinon s donne la signature de l'erreur $e$
  ]
  // Possible décodage par syndrome
]

#myslide("Exemple d'un code linéaire")[
  #[
    #set text(size: 1.1em)
    #let col-u = blue
    #let col-p = orange


    #underline(offset: 3pt)[Exemple d'un code $(5,2)$]


    - On choisit la matrice de parité $P$ :
    $
      P = #math.mat(
        (text(fill: col-p)[1], text(fill: col-p)[1], text(fill: col-p)[0]),
        (text(fill: col-p)[0], text(fill: col-p)[1], text(fill: col-p)[1]),
      )
    $

    - Alors la matrice génératrice $G$ est :
    $
      G = #math.mat(
        (text(fill: col-u)[1], text(fill: col-u)[0], text(fill: col-p)[1], text(fill: col-p)[1], text(fill: col-p)[0]),
        (text(fill: col-u)[0], text(fill: col-u)[1], text(fill: col-p)[0], text(fill: col-p)[1], text(fill: col-p)[1]),
        augment: 2,
      )
    $

    - Message $display(u = #math.mat((text(fill: col-u)[1], text(fill: col-u)[1])))$

    - Mot de code $c = u G$ :
    $
      c = #math.mat((text(fill: col-u)[1], text(fill: col-u)[1]))
      #math.mat(
        (text(fill: col-u)[1], text(fill: col-u)[0], text(fill: col-p)[1], text(fill: col-p)[1], text(fill: col-p)[0]),
        (text(fill: col-u)[0], text(fill: col-u)[1], text(fill: col-p)[0], text(fill: col-p)[1], text(fill: col-p)[1]),
        augment: 2,
      )
      =
      #math.mat((
        text(fill: col-u)[1],
        text(fill: col-u)[1],
        text(fill: col-p)[1],
        text(fill: col-p)[0],
        text(fill: col-p)[1],
      ))
    $
  ]
]

#myslide("Exemple d'une code linéaire")[
  #[
    #set math.mat(delim: "[")
    #let colu = blue
    #let colp = orange

    #v(0.5em)

    #set text(size: 1.1em)
    Enfin

    $
      H = #math.mat(
        (text(fill: colp)[1], text(fill: colp)[0], 1, 0, 0),
        (text(fill: colp)[1], text(fill: colp)[1], 0, 1, 0),
        (text(fill: colp)[0], text(fill: colp)[1], 0, 0, 1),
        augment: 2,
      )
    $

    #v(0.8em)

    Vérification du mot de code $display(c = mat(#text(fill: colu)[1], #text(fill: colu)[1], #text(fill: colp)[1], #text(fill: colp)[0], #text(fill: colp)[1]))$

    #v(0.8em)

    $
      H c^top = mat(
        1, 0, 1, 0, 0;
        1, 1, 0, 1, 0;
        0, 1, 0, 0, 1
      ) mat(#text(fill: colu)[1], #text(fill: colu)[1], #text(fill: colp)[1], #text(fill: colp)[0], #text(fill: colp)[1])^top
      = mat(
        1 plus.o 0 plus.o 1 plus.o 0 plus.o 0;
        1 plus.o 1 plus.o 0 plus.o 0 plus.o 0;
        0 plus.o 1 plus.o 0 plus.o 0 plus.o 1
      )
      = mat(0; 0; 0)
    $
  ]
]

// A REMPLACER AVEC DE VRAI DONNE SUR DE VRAI CODE LDPC ET HAMMING PAR EXEMPLE
#myslide("Approcher la Limite de Shannon")[
  #limite_shannon_graphique()

]

// #myslide("Redondance et limite théorique")[
//   Graphique waterfall avec n = 100 et n = 64800 avec limite de Shannon, $display(R = k /n) < 1$, $m = n - k$
//
//   Bande passante...
//
//   Il existe $C$ pour un canal tel que pour $R < C$ on peut atteindre une probabilité d'erreur nulle.
//   $=>$ gros bloc (moyenne du bruit aléatoire)
// ]

#myslide("Décodage par Maximum de Vraisemblance")[
  Trouver le message envoyer le + probable sachant le message recu : NP-COMPLET (Max)
  Decodage par syndrome d'une code lin'aire général est NP-Complet
  Complexité $O(2^k)$
]

#myslide("LDPC")[
  Matrice $H$ clairsemée(low density) donc complexité mointre, pas de produit de matrice mais algorithme itératif efficace quasi linéaire
  Graphique d'un H très grand clairesemée avec plein de 0, généré en rust par exemple où les 1 sont des points noir et le reste du blanc
  Défniition avec (w_r,w_c)
]

#myslide("Graphe de Tanner")[
  Il existe un isomorphisme entre H et le Graphe de Tanner
  Graphe de tanner (cetz)
  Contrainte de somme nulle
]

#myslide("Encodage")[
]

#myslide("Décodage")[
  Canal d'étude (AWGN) analogique, tension etc, ce qui se passe en radio dans les cables etc
]

#myslide("Hard decoding")[
  Nul (0 ou 1)
  transition perte d'information
]

#myslide("Implementation")[

]

#myslide("Soft decoding")[
  belief propagation, log ou virgule fixe, explication resultat meilleur
]

#myslide("Implementation")[

]

#myslide("Test")[
  Irl hackrf, test de diff de debit avec des paquets
]

#myslide("Image")[
  Test de transmission d'image avec différent ldpc non opti et opti (le H)
]

#myslide("Annexe")[
  #align(center + horizon)[
    Annexe
  ]
  #align(center + horizon)[
    #image("src/construction.jpg", width: 80%)
  ]
]

#myslide("Théorie deriere la définition des codes linaires")[
  Poser les notations algebriques etc...
]
